package org.spolo.android.tween;

import org.spolo.android.nodetree.Vcanvas;

public class FloatInterpolate extends InterpolateBase {
	private float taget_Value;
	private float howlong;

	private float lastdx = 0;

	/**
	 * @param v
	 * @param y
	 * @param time
	 */
	public FloatInterpolate(Vcanvas v, float y, long time) {
		super(v);
		this.taget_Value = y;
		this.howlong = time;
	}

	@Override
	public void stepIt(long tick) {
		float dx = taget_Value;
		float factor = ((tick - startTick) / this.howlong);
		if (factor > 1.0) {
			this.isFinish = true;
			return;
		}
		float mx = factor * dx - lastdx;
		lastdx = factor * dx;
		this.Target.Rotate(mx);
		this.isFinish = factor > 1.0;
	}
}
